<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/29 0029
 * Time: 16:03
 */

namespace app\home\controller;
use think\Db;

class Video extends Base
{
        public function index($id=0){
            session('video_id',0);
            //轮播图
            $data_banner = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=41')->order('sort desc,id desc')->field('banner_img,out_link')->select();
            $this->assign('data_banner',$data_banner);
            //客片底部广告
            $data_bannerfont = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=43')->order('sort desc,id desc')->field('banner_img,out_link')->limit(1)->find();
            $this->assign('data_bannerfont',$data_bannerfont);
            //内容
            if(!empty($id)){
                session('video_id',$id);
                $where=[
                    'w.sign'=>"pc",
                    'w.is_del'=>0,
                    'w.is_show'=>1,
                    'c.class_id'=>$id,
                    'w.is_recom'=>1
                ];
                $data_video = Db::name('video')->alias('w')->join('vclass c','w.class_id=c.class_id')
                    ->where($where)->order('w.sort desc,w.id desc')
                    ->field('w.id,w.video_img,w.video_url,w.create_time,w.seo_description,w.out_link,w.click,w.title,c.name,c.class_id')
                    ->select();
                $data_class=  Db::name('vclass')->where('show',1)->order('class_id asc')->limit(3)->select();
            }else{
                $where=[
                    'w.sign'=>"pc",
                    'w.is_del'=>0,
                    'w.is_show'=>1,
                    'w.is_recom'=>1
                ];
                $data_video = Db::name('video')->alias('w')->join('vclass c','w.class_id=c.class_id')
                    ->where($where)->order('w.sort desc,w.id desc')
                    ->field('w.id,w.video_img,w.video_url,w.create_time,w.seo_description,w.out_link,w.click,w.title,c.name,c.class_id')
                    ->select();
                $data_class=  Db::name('vclass')->where('show',1)->order('class_id asc')->limit(3)->select();
            }
            $this->assign('data_class',$data_class);
            $this->assign('data_video',$data_video);
            $this->assign('data_seo',getColumnseo(7));
            return $this->fetch();
        }



}